<template>
    <div class="page">
        <leftBar @leftEvent="getBaseInfo" />
        <div class="page_one">
            <el-image
                style="width:596px; height:820px"
                :src="url"
                @click="goPage"
                fit="cover">
            </el-image>
        </div>
        <el-button class="download" type="primary" icon="el-icon-download" @click="createUrl" v-if="false">导出PDF</el-button>
    </div>
</template>

<script>
    import { index_data } from '@/assets/js/getData';
    import leftBar from '@/components/leftBar.vue'
    import { mapState } from 'vuex';
    export default {
        name: 'index',
        data(){
            return {
                date:'',
                url: '',
                imgArr:[],//需要打印的pdf图片
                loading:''
            }
        },
        components: {
            leftBar
        },
        computed:{
            ...mapState([
                'baseInfo'
            ]),
            isLoad:function(){
                return this.baseInfo.year;
            }
        },
        watch:{
            isLoad:function(val){
                if(val){
                    this.date = this.baseInfo.year + '-' + this.baseInfo.month;
                    this.init();
                }
            }
        },
        mounted(){
            if(this.baseInfo.year){
                this.date = this.baseInfo.year + '-' + this.baseInfo.month;
                this.init();
            }
        },
        methods:{
            async init(){
                const res = await index_data({data:encodeURI(JSON.stringify({yf:this.date}))});
                if(res.code == '0'){
                    this.url = res.data.url+'&spec=600';
                }else{
                    this.$message({
                        showClose:true,
                        message: res.message,
                        type: 'error'
                    });
                }
            },
            goPage(){
                this.$router.push('/designer');
            },
            getBaseInfo(res){
                this.date = res.year+'-'+res.month;
                this.url = res.url;
            }
        }
    }
</script>

<style scoped>
    .download{position: absolute;right:150px;bottom:100px;background:#5B8CFF;border-radius:0;display:flex;align-items: center;padding-top:10px;padding-bottom:10px;}
    .download >>> i{font-size:20px;}
    .download:hover{opacity:0.9;}
</style>